<template>
  <div>
     查询条件输入
        <el-row :gutter="20">


          <el-col :span="8">
            <el-input label="请输入客户名称" v-model="customerName" placeholder="请输入客户名称"></el-input>
          </el-col>

          <el-col :span="8">
            <el-input label="请输入城市名称" v-model="address" placeholder="请输入城市名称"></el-input>
          </el-col>





          <el-col :span="8">
            <el-form>
              <el-form-item>
                <el-button type="primary" @click="handleSearch">查询</el-button>
              </el-form-item>
            </el-form>
          </el-col>


        </el-row>






    <!-- 展示查询数据 -->
    <el-table :data="customers" style="width: 100%">
      <el-table-column prop="customerId" label="客户编号" width="180"></el-table-column>
      <el-table-column prop="customerName" label="客户名称" width="180"></el-table-column>
      <el-table-column prop="contactPerson" label="联系人" width="180"></el-table-column>
      <el-table-column prop="email" label="邮件" width="180"></el-table-column>
      <el-table-column prop="phone" label="电话" width="180"></el-table-column>
      <el-table-column prop="address" label="地址" width="180"></el-table-column>
      <el-table-column prop="createdTime" label="添加时间" width="180"></el-table-column>

      <el-table-column label="操作" width="180">

      </el-table-column>
    </el-table>

    <!-- 查看详情的对话框 -->
<!--    <el-dialog title="商品详情" v-model="dialogVisible">-->
<!--      <el-table :data="detailList">-->
<!--        <el-table-column prop="brand" label="商品品牌"></el-table-column>-->
<!--        <el-table-column prop="productName" label="商品名称"></el-table-column>-->
<!--        <el-table-column prop="typeName" label="包装类型"></el-table-column>-->
<!--        <el-table-column prop="weight" label="体积/重量"></el-table-column>-->
<!--        <el-table-column prop="price" label="进货价"></el-table-column>-->
<!--        <el-table-column prop="total" label="数量"></el-table-column>-->
<!--      </el-table>-->
<!--      <template #footer>-->
<!--        <span class="dialog-footer">-->
<!--          <el-button @click="dialogVisible = false">关闭</el-button>-->
<!--        </span>-->
<!--      </template>-->
<!--    </el-dialog>-->

  </div>
</template>

<script setup>
import { ref } from 'vue'
import {selectCustomer} from "../../../api/sale/customer";

// const priceListVoLists=ref([])
const customers=ref([])
const customerName=ref('');
const address=ref('')
handleSearch();

function handleSearch(){
  selectCustomer(customerName.value,address.value).then(res=>{
    customers.value=res.customerList;
    customers.value.forEach(item=>{
      item.createdTime=formatDate(new Date(item.createdTime));
    })
  })
}
const formatDate = (date) => {
  const year = date.getFullYear();
  const month = String(date.getMonth() + 1).padStart(2, '0'); // 月份从0开始，所以加1
  const day = String(date.getDate()).padStart(2, '0');

  return `${year}-${month}-${day}`;
};

// 查看详情


</script>

<style scoped>
/* 可以在这里添加一些样式 */
</style>
